<template>
  <!-- 主体区域 -->
  <section id="app">
    <TodoHeader @add="addTodo"></TodoHeader>
    <TodoMain :list="list"></TodoMain>
    <TodoFooter></TodoFooter>
  </section>
</template>

<script>
import TodoHeader from "./components/TodoHeader";
import TodoMain from "./components/TodoMain";
import TodoFooter from "./components/TodoFooter";
export default {
  data() {
    return {
      list: [
        { id: 1, title: "吃饭" },
        { id: 2, title: "睡觉" },
        { id: 3, title: "打豆豆" },
      ],
    };
  },
  methods: {
    addTodo(todoText) {
      this.list.unshift({
        id: this.list.length + 1,
        title: todoText,
      });
    },
  },
  components: {
    TodoHeader,
    TodoMain,
    TodoFooter,
  },
};
</script>

<style>
</style>
